<template>
  <div class="modelInterfaceMain">
    <div class="modelInterfaceBox" v-if="apiList.length > 0">
      <div class="itemBox" v-for="(item, index) in apiList" :key="index" v-loading="loading">
        <img src="@/assets/images/interfaceIcon.png" alt="接口">
        <h3 class="ellipsis flex align-center">
          <el-tag size="mini" type="success" effect="dark" style="margin-right: 10px;">
            模型接口
          </el-tag>
          {{ item.name }}
        </h3>
        <p class="brief">
          {{ item.description }}
        </p>
        <div class="remark">
          备注：{{ item.remark }}
        </div>
      </div>
      <!--fanye-->
      <div class="fanye flex align-center justify-end">
        <div>
          <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </div>
      </div>
    </div>
    <div class="modelInterfaceBox" v-else>
      <div style="padding: 100px 0;" class="flex align-center justify-center">
        <el-empty description="暂无接口数据" :image-size="100"></el-empty>
      </div>
    </div>
  </div>
</template>
<script>
import {listApiInfoForIndex} from '@/api/model/apiCollection'

export default {
  name: '',
  props: {
    basicInfoId: {
      type: String,
      required: true,
    }
  },
  components: {},
  data() {
    return {
      loading: false,
      apiList: [],
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      }
    }
  },
  computed: {},
  watch: {
    basicInfoId: {
      handler(val) {
        this.getList(val);
      },
      deep: true,
      immediate: true
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {
    getList(basicInfoId) {
      this.loading = true;
      this.queryParams.basicInfoId = basicInfoId;
      listApiInfoForIndex(this.queryParams).then(response => {
        this.apiList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    }
  },
}
</script>
<style lang="scss" scoped>
.modelInterfaceBox {
  padding-bottom: 28px;

  .itemBox {
    padding: 32px 32px 28px 140px;
    -webkit-box-shadow: 0 4px 8px 0 rgba(28, 31, 33, 0.1);
    box-shadow: 0 4px 8px 0 rgba(28, 31, 33, 0.1);
    border-radius: 8px;
    position: relative;
    margin-top: 12px;
    background: #fff;

    img {
      width: 100px;
      height: 100px;
      display: block;
      position: absolute;
      top: 50%;
      left: 20px;
      margin-top: -50px;
    }

    h3 {
      font-size: 16px;
      color: #333;
      font-weight: bold;
      margin: 0 0 15px;
    }

    .brief {
      background-color: #F5F8F4;
      padding: 15px;
      color: #333333;
      border-radius: 4px;
      font-size: 14px;
      line-height: 22px;
    }

    .remark {
      font-size: 14px;
      color: #999;
    }
  }

  .fanye {
    padding-top: 28px;
  }
}
</style>
